package com.ruoyi.system.mapper;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.ruoyi.system.domain.Orderr;
import org.apache.ibatis.annotations.Select;

/**
 * 测试Mapper接口
 * 
 * @author ruoyi
 * @date 2024-12-11
 */
public interface OrderrMapper 
{
    /**
     * 查询测试
     *
     * @param recordId 测试主键
     * @return 测试
     */
    public Orderr selectOrderrByRecordId(Long recordId);

    /**
     * 查询测试列表
     *
     * @param orderr 测试
     * @return 测试集合
     */
    public List<Orderr> selectOrderrList(Orderr orderr);

    /**
     * 新增测试
     *
     * @param orderr 测试
     * @return 结果
     */
    public int insertOrderr(Orderr orderr);

    /**
     * 修改测试
     *
     * @param orderr 测试
     * @return 结果
     */
    public int updateOrderr(Orderr orderr);

    /**
     * 删除测试
     *
     * @param recordId 测试主键
     * @return 结果
     */
    public int deleteOrderrByRecordId(Long recordId);

    /**
     * 批量删除测试
     *
     * @param recordIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteOrderrByRecordIds(Long[] recordIds);

    @Select("SELECT COUNT(*) AS orderr_count,COALESCE(SUM(price), 0) AS orderr_price FROM orde WHERE DATE(receive_time) LIKE concat(#{receiveTime},'%')")
    public Map countOrderTime(String receiveTime);

    @Select("SELECT s.dict_label name, count(o.record_id) total_orders,COALESCE(SUM(price),0) price FROM orde o RIGHT JOIN sys_dict_data s on s.dict_value = o.orde_source AND DATE(o.receive_time) = #{recordDate} WHERE s.dict_type = 'orde_source' GROUP BY s.dict_label;")
    public List<Map> countOrderSource(String recordDate);
    @Select("SELECT s.property_name name, count(o.record_id) total_orders, COALESCE(SUM(price),0) price FROM orde o RIGHT JOIN property s on o.staff_property = s.property_id AND DATE(o.receive_time) = #{recordDate1} GROUP BY s.property_id;")
    public List<Map> countOrderSource1(String recordDate1);

    @Select("SELECT DATE_FORMAT(receive_time, '%m-%d') AS order_date, COUNT(*) AS num,SUM(price) AS price FROM orde WHERE DATE(receive_time) >= CURDATE() - INTERVAL 7 DAY GROUP BY DATE_FORMAT(receive_time, '%m-%d');")
    public List<Map> countOrder();

    @Select("SELECT t.time_name name, count(o.record_id) total_orders FROM orde o RIGHT JOIN time t ON t.time_id = o.time AND DATE(o.receive_time) = DATE_ADD(curdate(), INTERVAL 1 DAY) GROUP BY t.time_id ORDER BY t.time_id;")
    public List<Map> tomorrow();

    @Select("SELECT s.dict_label, count(o.record_id) total_orders FROM orde o RIGHT JOIN sys_dict_data s ON o.vip_type = s.dict_value AND DATE(o.receive_time) = DATE_ADD(curdate(), INTERVAL 1 DAY) WHERE s.dict_type = 'vip_type' GROUP BY s.dict_label;")
    public List<Map> vipType();

    @Select("SELECT COUNT(record_id) yn_money FROM orde WHERE yn_money = '0'  ")
    public int ynMoney();

    @Select("SELECT  count(o.record_id) total_orders FROM orde o RIGHT JOIN sys_dict_data s ON o.orde_source = s.dict_value AND DATE(o.receive_time) = DATE_ADD(curdate(), INTERVAL 1 DAY) WHERE s.dict_type = 'orde_source' GROUP BY s.dict_label;")
    public List<Map> ordeSourceT();

    @Select("SELECT count(*) FROM orde o WHERE `status`='2'AND DATE(o.receive_time) =  DATE_ADD(curdate(), INTERVAL 1 DAY)")
    public int ordestatus2();

    @Select("SELECT count(*) FROM orde o WHERE  DATE(o.receive_time) =  DATE_ADD(curdate(), INTERVAL 1 DAY)")
    public int ordestatusall();

    @Select("SELECT COUNT(vip_id) FROM vip WHERE vip_endtime >= CURDATE() AND vip_endtime < CURDATE() + INTERVAL 3 DAY;")
    public int vipEndtime();

    @Select("SELECT COUNT(*) FROM orde WHERE tousu IS NOT NULL;")
    public int tousu();
}
